package com.simple.controller;

import com.simple.common.PageResult;
import com.simple.common.Result;
import com.simple.dto.AmountDTO;
import com.simple.dto.BillDTO;
import com.simple.service.AmountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName BillController
 * @Author SimpleTree
 **/
@RestController
@RequestMapping("/amount")
public class AmountController {

    @Autowired
    private AmountService amountService;

    @GetMapping
    public Result getAmounts(AmountDTO amountDTO) {
        return Result.of(amountService.getAmounts(amountDTO));
    }
    @GetMapping("/getAmountById/{id}")
    public Result getAmountById(@PathVariable Integer id) {
        return Result.of(amountService.getAmountById(id));
    }

    @PostMapping
    public Result saveAmount(@RequestBody AmountDTO amountDTO) {
        amountService.saveAmount(amountDTO);
        return Result.of();
    }

    @PutMapping
    public Result updateAmount(@RequestBody AmountDTO amountDTO) {
        amountService.updateAmount(amountDTO);
        return Result.of();
    }

    @DeleteMapping
    public Result deleteByIds(@RequestParam List<Integer> ids) {
        amountService.deleteByIds(ids);
        return Result.of();
    }
}
